package com.tmxk.servlet;

import com.tmxk.bean.NewsBean;
import com.tmxk.dao.NewsDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/newsDetail.html")
public class NewsDetailServelt extends HttpServlet {
        protected void doGet(HttpServletRequest req, HttpServletResponse resp)
                throws ServletException, IOException{
            String NewsId = req.getParameter("NewsId");
            int id = Integer.parseInt(NewsId);
            NewsBean newsBean = (new NewsDao()).getNewsByID(id);
            req.setAttribute("title",newsBean.getNewsTitle());
            req.setAttribute("content",newsBean.getNewsContent());
            req.getRequestDispatcher("newsFrontDetail.jsp").forward(req, resp);
        }
    }

